package aod.android.com.bernay.mine.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;

import aod.android.com.bernay.R;
import aod.android.com.bernay.mine.module.DynamicBean;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;

/**
 * @author crated by zhixianuanyang on 2019/4/9 15:44
 * @Email jamesKing0812@gmail.com
 */
public class VideoViewHolder extends RecyclerView.ViewHolder {

    private final Context mContext;
    public JCVideoPlayer mVideoPlayer;
    public ImageView vedioStatus;
    public TextView textStatus;
    public TextView vedioCreatTime;
    public TextView vedioContent;
    public LinearLayout layoutFabulous;
    public TextView vedioFabulous;
    public LinearLayout layoutComment;
    public TextView vedioComment;

    public VideoViewHolder(View itemView, Context mContext) {
        super(itemView);
        this.mContext = mContext;
        mVideoPlayer = (JCVideoPlayer) itemView.findViewById(R.id.mNiceVideoPlayer);
        vedioStatus = itemView.findViewById(R.id.iv_vedio_status);
        textStatus = itemView.findViewById(R.id.tv_vedio_status);
        vedioCreatTime = itemView.findViewById(R.id.tv_vedio_creatTime);
        vedioContent = itemView.findViewById(R.id.tv_vedio_content);
        layoutFabulous = itemView.findViewById(R.id.ll_vedio_fabulous);
        vedioFabulous = itemView.findViewById(R.id.tv_vedio_fabulous);
        layoutComment = itemView.findViewById(R.id.ll_vedio_comment);
        vedioComment = itemView.findViewById(R.id.tv_vedio_comment);
    }

    public void bindData(final DynamicBean videoBean) {

        mVideoPlayer.setUp(videoBean.getVideoLink(),videoBean.getImageUrl(),"");
        Glide.with(mContext)
                .load(videoBean.getImageUrl())
                .into(mVideoPlayer.ivStart);
        if (videoBean.getAuditStatus().equals("1")){
            vedioStatus.setVisibility(View.GONE);
            textStatus.setText("审核中");
        }else{
            vedioStatus.setVisibility(View.VISIBLE);
            textStatus.setText("已审核");
        }

        vedioCreatTime.setText(videoBean.getReleaseTime());
        vedioContent.setText(videoBean.getTextContent());
        vedioFabulous.setText(videoBean.getThumbsUp());
        vedioComment.setText(videoBean.getReplyMessage());
        layoutFabulous.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mContext,videoBean.getThumbsUp(),Toast.LENGTH_SHORT).show();
            }
        });

        layoutComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mContext,videoBean.getReplyMessage(),Toast.LENGTH_SHORT).show();
            }
        });

    }
}
